package com.zqq.glide.touchView;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

/**
 * 自定义view检查touch事件
 * 1.
 *
 *
 * @author zqq on 2018/7/16
 */
public class LayoutView1 extends RelativeLayout {

    private final String TAG = "Tag--";

    public LayoutView1(Context context) {
        super(context);
    }

    public LayoutView1(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "LayoutView1 Intercept DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "LayoutView1 Intercept MOVE");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG, "LayoutView1 Intercept UP");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.e(TAG, "LayoutView1 Intercept CANCEL");
                break;
            default:
                break;
        }
        return false;
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "LayoutView1 Touch DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "LayoutView1 Touch MOVE");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG, "LayoutView1 Touch UP");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.e(TAG, "LayoutView1 Touch CANCEL");
                break;
            default:
                break;
        }
        return false;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.e(TAG, "LayoutView1  dispatch   ");
        boolean r = super.dispatchTouchEvent(ev);
        Log.e(TAG, "LayoutView1  dispatch 结果   " + r);
        return r;
    }

}
